<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>watch监听器</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
</head>
<body>
<center>
    <div id="app">
        <input type="text" v-model="number">
        <h1>改变之前的值：{{oldP}}, 改变之后的值：{{newP}}</h1>
    </div>

</center>
</body>

<script type="text/javascript">
    // 实例化vue对象
    let vm  =new Vue({
        el: "#app",
        data: {
            number: 0,
            newP: null,
            oldP: null
        },
        // 监听器属性
        watch: {
            number(newParam, oldParam){
                this.newP = newParam;
                this.oldP = oldParam;
            }
        }
    });
</script>
</html>